package day10;

/**
 * 题目链接(#字棋)
 * https://www.nowcoder.com/practice/e1bb714eb9924188a0d5a6df2216a3d1?tpId=8&&tqId=11055&rp=1&ru=/activity/oj&qru=/ta/cracking-the-coding-interview/question-ranking
 */
public class Main {
    public static boolean func(int[][] array) {
        int size = array.length;
        int sum = 0;
        //检查行
        for (int i = 0; i < size; i++) {
            sum = 0;
            for (int j = 0; j < size; j++) {
                sum += array[i][j];   //行不变
            }
            if(sum == size) {
                return true;
            }
        }
        //检查列
        for (int i = 0; i < size; i++) {
            sum = 0;
            for (int j = 0; j < size; j++) {
                sum += array[j][i];      //列不变
            }
            if(sum == size) {
                return true;
            }
        }
        sum = 0;
        //检查主对角线
        for (int i = 0; i < size; i++) {
            sum += array[i][i];
        }
        if(sum == size) {
            return true;
        }
        sum = 0;
        //检查副对角线
        for (int i = 0; i < size; i++) {
            sum += array[i][size-i-1];    //(3行3列副对角线开始array[0][2])
        }
        if(sum == size) {
            return true;
        }
        return false;
    }

    public static void main(String[] args) {
        int[][] array = new int[3][3];

    }
}
